package com.ruoyi.slope.video.lidar.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.video.lidar.domain.SlopeLidarMonitor;
import com.ruoyi.slope.video.lidar.service.ISlopeLidarMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 点云雷达监测信息Controller
 * 
 * @author ruoyi
 * @date 2025-05-11
 */
@RestController
@RequestMapping("/video/lidar")
public class SlopeLidarMonitorController extends BaseController
{    
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private ISlopeLidarMonitorService slopeLidarMonitorService;

    /**
     * 查询点云雷达监测信息列表
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeLidarMonitor slopeLidarMonitor)
    {
        startPage();
        List<SlopeLidarMonitor> list = slopeLidarMonitorService.selectSlopeLidarMonitorList(slopeLidarMonitor);
        return getDataTable(list);
    }

    /**
     * 导出点云雷达监测信息列表
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:export')")
    @Log(title = "点云雷达监测信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeLidarMonitor slopeLidarMonitor)
    {
        List<SlopeLidarMonitor> list = slopeLidarMonitorService.selectSlopeLidarMonitorList(slopeLidarMonitor);
        ExcelUtil<SlopeLidarMonitor> util = new ExcelUtil<SlopeLidarMonitor>(SlopeLidarMonitor.class);
        String path = util.exportExcel(response, list, "点云雷达监测信息数据"); 
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取点云雷达监测信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeLidarMonitorService.selectSlopeLidarMonitorById(id));
    }

    /**
     * 新增点云雷达监测信息
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:add')")
    @Log(title = "点云雷达监测信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeLidarMonitor slopeLidarMonitor)
    {
        return toAjax(slopeLidarMonitorService.insertSlopeLidarMonitor(slopeLidarMonitor));
    }

    /**
     * 修改点云雷达监测信息
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:edit')")
    @Log(title = "点云雷达监测信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeLidarMonitor slopeLidarMonitor)
    {
        return toAjax(slopeLidarMonitorService.updateSlopeLidarMonitor(slopeLidarMonitor));
    }

    /**
     * 删除点云雷达监测信息
     */
    @PreAuthorize("@ss.hasPermi('video:lidar:remove')")
    @Log(title = "点云雷达监测信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeLidarMonitorService.deleteSlopeLidarMonitorByIds(ids));
    }
}
